<%@ page import="java.net.URLDecoder" %><%--
  Created by IntelliJ IDEA.
  User: 段生伟
  Date: 2022/2/23
  Time: 9:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>

    <title>Title</title>
</head>
<body>
<%
    Cookie cookie = null;
    Cookie[] cookies = null;
    cookies = request.getCookies();
    for (int i = 0; i < cookies.length; i++) {
        cookie = cookies[i];
        if ((cookie.getName()).compareTo("login") == 0){
            String username = URLDecoder.decode(cookie.getValue(),"utf-8");
            if (username.equals("admin")){
                session.setAttribute("login",username);
                response.sendRedirect("welcome.jsp");
            }
    }}
%>
 <form action="user.jsp">
     <p>登录<input type="text" name="username"></p>
     <p>密码<input type="password" name="password"></p>
     <p>性别<input type="radio" name="sex">男
            <input type="radio" name="sex">女</p>
     <p> <input type="submit" value="提交"></p>
 </form>
</body>
</html>
